<script setup>
import { ref } from 'vue'
import { useUserStore } from '@/stores/userStore'

const baseUrl = '/userCenter'
const userStore = useUserStore()


</script>

<template>
<div class="userCenter-page">
    <div class="page-header">
        <div class="header-container">
            <div class="header-l">欢迎使用融销通！</div>
            <div class="header-r"><RouterLink to="/">回到首页</RouterLink></div>
        </div>
    </div>
    <div class="page-body">
        <div class="tabs">
            <RouterLink :to="`${baseUrl}/userInfo`" active-class="active">我的信息</RouterLink>
            <RouterLink :to="`${baseUrl}/order`" active-class="active">我的订单</RouterLink>
            <template v-if="userStore.userInfo?.role === 'user'">
                <RouterLink :to="`${baseUrl}/question`" active-class="active">我的提问</RouterLink>
            </template>
            <!-- <RouterLink :to="`${baseUrl}/remark`" active-class="active">我的评论</RouterLink> -->
            <RouterLink :to="`${baseUrl}/finance`" active-class="active">我的融资</RouterLink>
            <RouterLink :to="`${baseUrl}/alterPwd`" active-class="active">修改密码</RouterLink>
            <RouterLink :to="`${baseUrl}/address`" active-class="active">地址管理</RouterLink>
            <RouterLink :to="`${baseUrl}/purchase`" active-class="active">采购管理</RouterLink>
            <RouterLink :to="`${baseUrl}/productManage`" active-class="active">商品管理</RouterLink>
            <RouterLink :to="`${baseUrl}/orderManage`" active-class="active">订单管理</RouterLink>
            <template v-if="userStore.userInfo?.role === 'expert'">
                <RouterLink :to="`${baseUrl}/expertInfo`" active-class="active">专家信息</RouterLink>
                <RouterLink :to="`${baseUrl}/knowledge`" active-class="active">我的发布</RouterLink>
                <RouterLink :to="`${baseUrl}/answer`" active-class="active">我的问答</RouterLink>
            </template>
        </div>
        <div class="tab-container">
            <!-- 二级级路由出口 -->
            <RouterView />
        </div>
    </div>
</div>
</template>

<style scoped lang='scss'>
$maxW: 1200px;

.page-header {
    width: 100%;
    height: 80px;
    background-color: #45b035;

    .header-container {
        display: flex;
        justify-content: space-between;
        width: $maxW;
        height: 100%;
        margin: 0 auto;

        .header-l {
            height: 100%;
            line-height: 80px;
            color: #fff;
            font-size: 22px;
        }

        .header-r {
            height: 100%;
            line-height: 80px;

            >a {
                color: #fff;
            }
        }
    }
}

.page-body {
    display: flex;
    justify-content: space-between;
    width: $maxW;
    min-height: 600px;
    margin: 20px auto;
    
    >div {
        background-color: #fff;
    }

    .tabs {
        width: 180px;

        >a {
            display: block;
            width: 100%;
            line-height: 22px;
            padding: 19px 0 19px 20px;
        }
    }

    .tab-container {
        width: 1000px;
        height: 740px;
        overflow: auto;
    }
}

.active {
    color: #fff;
    background-color: #45b035;
}
</style>